package com.example.project.service.impl;

import org.springframework.beans.factory.annotation.Autowired;

import com.example.message.mapper.MessageMapper;
import com.example.message.mapper.MessageReceiveMapper;
import com.example.message.service.MessageService;
import com.example.project.entity.User;
import com.example.project.mapper.IssueRelationMapper;
import com.example.project.mapper.UserMapper;
import com.example.project.mapper.WatcherMapper;
import com.example.project.service.CommonService;
import com.example.project.utils.ShiroUtils;

/**
 * 服务实现基类
 * 
 * @param <M> Mapper类型
 * @param <T> 实体类型
 */
public class BaseServiceImpl {

	@Autowired
	protected IssueRelationMapper issueRelationMapper;

	@Autowired
	protected WatcherMapper watcherMapper;

	@Autowired
	protected UserMapper userMapper;

	@Autowired
	protected MessageReceiveMapper messageReceiveMapper;

	@Autowired
	protected MessageMapper messageMapper;

	// 这里已经实现了IService的所有基本方法
	// 子类可以继承这些方法，也可以根据需要重写

	/**
	 * 获取用户缓存信息
	 */
	public User getUser() {
		return ShiroUtils.getSysUser();
	}

	/**
	 * 设置用户缓存信息
	 */
	public void setUser(User user) {
		ShiroUtils.setSysUser(user);
	}

	/**
	 * 获取登录用户id
	 */
	public Long getUserId() {
		return getUser().getUserId();
	}

	/**
	 * 获取登录用户名
	 */
	public String getLoginName() {
		return getUser().getLoginName();
	}
}